﻿# coding:utf-8

class DataOutputer(object):
    def __init__(self, output_file):
        self.f = open(output_file, 'w')
    
    def output(self, datas, output_file):
        self.f.write('<html>')
        self.f.write('<body>')
        self.f.write('<table>')
        for data in datas:
            self.f.write('<tr>')
            self.f.write('<td>%s</td>' %data.get('name').encode('utf-8').strip())
            self.f.write('<td>%s</td>' %data.get('content').encode('utf-8').strip())
            self.f.write('<td>%s</td>' %data.get('funny'))
            self.f.write('<td>%s</td>' %data.get('review'))
            self.f.write('</tr>')
        self.f.write('</table>')
        self.f.write('</body>')
        self.f.write('</html>')
        self.f.flush()
    
    def close(self):
        self.f.close()
    